# frozen_string_literal: true

class VariableTypesController < ApplicationController
  def index
    render json: VariableTypeService.search(params)
  end

  def show
    render json: VariableTypeService.show(params.require(:id))
  end

  def create
    render json: VariableTypeService.create(variable_type_params.permit(:name, :klass))
  end

  def update
    render json: VariableTypeService.update(
      params.require(:id),
      variable_type_params.permit(:name, :klass, :status)
    )
  end

  def destroy
    render json: VariableTypeService.delete(params.require(:id))
  end

  private

  def variable_type_params
    params.require :variable_type
  end
end
